
import tldextract
import httplib

y=10
z=20
for x in range(0,3):
    print x
    if x <2 :
        continue
    print y
    print z

    
str  = "http:///hell///hi"
link = str.replace("///", "//")
print link

val = tldextract.extract('http://gmail.com/')
print val
print val[0], val[1], val[2]
#ExtractResult(subdomain='forums.news', domain='cnn', tld='com')
tldextract.extract('http://forums.bbc.co.uk/') # United Kingdom
#ExtractResult(subdomain='forums', domain='bbc', tld='co.uk')
tldextract.extract('http://www.worldbank.org.kg/') # Kyrgyzstan

import re
link = "https://XX.XX.XX.XX:2087/"
link = re.sub('https?://[-\.\*\?\[\]\(\)@&%!~`^$#{}/X:]+[0-9]+/?$','http//',link)
link =re.sub('https?://[0-9\.]+/?$','',link)
link =re.sub('https?://localhost/?$','',link)
link =re.sub('https?://hostname/?$','',link)
print "new link", link

#ExtractResult(subdomain='www', domain='worldbank', tld='org.kg')
